﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net.Mail;
using System.Net.Sockets;

using SosForms;
using SosBL;
using SosData;


namespace UOCmaker
{
    public partial class FormUOCsais : FormDetalle
    {

        #region " Constructores "

        /// <summary>
        /// Constructor
        /// </summary>
        public FormUOCsais()
        {
            InitializeComponent();
        }

        Plantilla _plantilla;
        sosContext db = null;
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="plantilla">plantilla</param>
        public FormUOCsais(Plantilla plantilla)
        {
            InitializeComponent();

            db = new sosContext();
            _plantilla = (from p in db.Plantillas.Include("PlantillaUOCMails").Where(p => p.Id == plantilla.Id) select p).FirstOrDefault();


            bindingSource.DataSource = _plantilla;
            bindingSource.DataMember = "PlantillaUOCMails";

            romGridView1.EndEdit();
            romGridView1.Refresh();

            this.ModoForm = _modoForm.Editar;
        }

        #endregion

        #region " Metodos "
        /// <summary>
        /// Guardar cambios
        /// </summary>
        public override void Guardar()
        {
            bindingSource.EndEdit();
            db.SaveChanges();
        }

        /// <summary>
        /// Cancelar cambios
        /// </summary>
        public override void Cancelar()
        {
            this.Close();
        }
        #endregion

    }
}
